home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / tcp / ftp / archie132.lha / archie-1.3.2 / src / get_pauth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-10  |  2.0 KB  |  92 lines

  1. /*
  2.  * Copyright (c) 1989, 1990 by the University of Washington
  3.  *
  4.  * For copying and distribution information, please see the file
  5.  * <copyright.h>.
  6.  */
  7.  
  8. #include <proto/usergroup.h>
  9.  
  10. #include <copyright.h>
  11. #include <stdio.h>
  12. #ifndef VMS
  13. # include <sys/types.h> /* this may/will define FD_SET etc */
  14. # include <pmachine.h>
  15. #endif
  16.  
  17. #ifdef NEED_STRING_H
  18. # include <string.h>
  19. #else
  20. # include <strings.h>
  21. #endif
  22.  
  23. #ifndef VMS
  24. # if defined(MSDOS) && !defined(OS2)
  25. #  ifndef CUTCP
  26. #   include <rwconf.h>
  27. #  endif
  28. # else
  29. #  include <pwd.h>
  30. # endif
  31. #else
  32. # include <jpidef.h>
  33. # include <vms.h>
  34. #endif
  35.  
  36. #include <pcompat.h>
  37. #include <pauthent.h>
  38.  
  39. PAUTH
  40. get_pauth(type)
  41.     int        type;
  42.     {
  43.     static PAUTH_ST   no_auth_st;
  44.     static PAUTH          no_auth = NULL;
  45. #if !defined(VMS) && !defined(MSDOS) || defined(OS2)
  46.     struct passwd *whoiampw;
  47. #else
  48.     char username[13];
  49.     unsigned short usernamelen;
  50.     struct {
  51.         unsigned short buflen;
  52.         unsigned short itmcod;
  53.         char *bufadr;
  54.         unsigned short *retlenadr;
  55.         unsigned long null;
  56.     } jpi_itemlist;
  57. #endif
  58.  
  59.     if(no_auth == NULL) {
  60.         no_auth = &no_auth_st;
  61.         strcpy(no_auth->auth_type,"UNAUTHENTICATED");
  62.  
  63.         /* find out who we are */
  64. #ifndef VMS
  65. #if defined(MSDOS) && !defined(OS2)
  66. #ifndef CUTCP
  67.         if (!getconf("general", "user", no_auth->authenticator, 250)
  68.         || (strlen (no_auth->authenticator) == 0))
  69. #endif
  70.           strcpy(no_auth->authenticator,"nobody");
  71. #else /* not MSDOS */
  72.         DISABLE_PFS(whoiampw = getpwuid(getuid()));
  73.         if (whoiampw == 0) strcpy(no_auth->authenticator,"nobody");
  74.         else strcpy(no_auth->authenticator, whoiampw->pw_name);
  75. #endif /* not MSDOS */
  76. #else
  77.         jpi_itemlist.buflen = sizeof(username);
  78.         jpi_itemlist.itmcod = JPI$_USERNAME;
  79.         jpi_itemlist.bufadr = &username;
  80.         jpi_itemlist.retlenadr = &usernamelen;
  81.         jpi_itemlist.null = 0;
  82.         if (SYS$GETJPI(0, 0, 0, &jpi_itemlist, 0, 0, 0) & 0x1)
  83.         {
  84.         username[usernamelen] = 0;
  85.         strcpy(no_auth->authenticator, username);
  86.         } else
  87.         strcpy(no_auth->authenticator, "nobody");
  88. #endif
  89.     }
  90.     return(no_auth);
  91.     }
  92.